﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

#if AGENTEDITOR
using FRL.DebtChased.AgentEditor;
#endif // #if AGENTEDITOR

#if CLIENTEDITOR
using FRL.DebtChased.ClientEditor;
#endif // #if CLIENTEDITOR

#if CHASEWORKSPACE
using FRL.DebtChased.ChaseWorkspace;
#endif // #if CHASEWORKSPACE

using FRL.DebtChased.Repository;
using FRL.DebtChased.RichContentService;

namespace FRL.DebtChased.Silverlight.Controls
{

	/// <summary>
	/// Declaration of ContactPointCtrl class
	/// </summary>
	public partial class ContactPointCtrl : UserControl
	{

		/////////////////////////////////////////////////////////////
		// Events

		public event RoutedEventHandler DeleteEvent;

		/////////////////////////////////////////////////////////////
		// Attributes

		private Definitions.eContactPointType m_pointType = Definitions.eContactPointType.NotSet;
		public Definitions.eContactPointType PointType
		{
			get { return m_pointType; }
		}

		private int m_iContactPointId = 0;
		public int ContactPointId
		{
			get { return m_iContactPointId; }
			set { m_iContactPointId = value; }
		}

		/////////////////////////////////////////////////////////////
		// Construction

		public ContactPointCtrl()
		{

			// Construction
			InitializeComponent();

		}

		/////////////////////////////////////////////////////////////
		// Operations

		public void Set(ContactPointTransport point)
		{

			// Set controls
			txtAddress.Text = point.Address;

			// Retain the id and type
			this.ContactPointId = point.ContactPointId;
			this.m_pointType = (Definitions.eContactPointType) point.ContactPointType;

		}

		public ContactPointTransport Get()
		{

			// Declare return variable
			ContactPointTransport Ftmp = new ContactPointTransport();

			// Update point members
			Ftmp.ContactPointId = this.ContactPointId;
			Ftmp.Address = txtAddress.Text;
			Ftmp.ContactPointType = (int)this.m_pointType;

			// Return variable
			return Ftmp;

		}

		private void butDelete_Click(object sender, EventArgs e)
		{

			// Fire event back to parent
			if (DeleteEvent != null)
				DeleteEvent(this, new RoutedEventArgs());

		}

		private void butQueue_Click(object sender, EventArgs e)
		{

			// Development message
			App.PopupDevMessage();

		}

	}

}
